package com.training.mapper;

import com.training.entity.TopicCategory;
import com.training.entity.TopicQuestion;
import com.training.entity.TopicQuestionComment;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;

@Mapper
public interface QaMapper {

    // 问题相关
    int createQuestion(TopicQuestion question);
    List<TopicQuestion> findQuestions(@Param("keyword") String keyword);
    TopicQuestion findQuestionById(@Param("id") Long id);
    void incrementViewCount(@Param("id") Long id);

    // 回答相关
    int createComment(TopicQuestionComment comment);
    List<TopicQuestionComment> findCommentsByQuestionId(@Param("qId") Long qId);
    TopicQuestionComment findCommentById(@Param("id") Long id);

    // 采纳相关
    int markAsAdopted(@Param("commentId") Long commentId);
    int markQuestionAsResolved(@Param("questionId") Long questionId);

    // 分类相关
    List<TopicCategory> findAllCategories();
    // 新增：根据用户ID查询该用户提出的所有问题
    List<TopicQuestion> findQuestionsByUserId(@Param("userId") Long userId);

    // 新增：根据用户ID查询该用户回答过的所有问题
    List<TopicQuestion> findQuestionsAnsweredByUserId(@Param("userId") Long userId);
}